#Include "Protheus.ch"

User Function TstIncPed()

Local aCabec := {}
Local aItens := {}

Private lMsErroAuto := .F.

AAdd(aCabec, {"C5_FILIAL" , xFilial("SC5"), Nil})
//AAdd(aCabec, {"C5_CLIENT" , M->CJ_CLIENTE, Nil})
//AAdd(aCabec, {"C5_LOJAENT", M->CJ_LOJA   , Nil})
//AAdd(aCabec, {"C5_VEND1"  , M->CJ_VEND   , Nil})
//AAdd(aCabec, {"C5_TRANSP" , "000888"     , Nil})
//AAdd(aCabec, {"C5_CONDPAG", M->CJ_CONDPAG, Nil})
//AAdd(aCabec, {"C5_TPFRETE", "C"          , Nil})
//AAdd(aCabec, {"C5_PEDCLI" , M->CJ_PEDIDOC, Nil})
//AAdd(aCabec, {"C5_COMIS1" , M->CJ_COMIS1 , Nil})
//AAdd(aCabec, {"C5_MENNOTA", M->CJ_LINHA  , Nil})
//AAdd(aCabec, {"C5_AGREG"  , M->CJ_LOTE   , Nil})
AAdd(aCabec, {"C5_TIPO", "N", Nil})
AAdd(aCabec, {"C5_CLIENTE", "003145", Nil})
AAdd(aCabec, {"C5_LOJACLI", "01", Nil})

AAdd(aItens, {{"C6_FILIAL" , xFilial("SC6"), Nil},;
              {"C6_ITEM"   , "01", Nil},;
              {"C6_PRODUTO", "000015", Nil},;
              {"C6_QTDVEN" , 10.00, Nil}})
              
BeginTran()
	lMsErroAuto := .F.
	MsExecAuto({|x, y, z| MATA410(x, y, z)}, aCabec, aItens, 3)
	IF lMsErroAuto
		MostraErro()
		DisarmTransaction()
		lRet := .F.
	EndIF
EndTran()

Return Nil